home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Applications / Calculators / NumberCrunch 1.41 / Number Crunch II Demo / Writing External Codes (xCOD) / FORTRAN source code / SAMPLE_XCOD.f < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.4 KB  |  50 lines  |  [TEXT/MPS ]

  1. C This is FORTRAN source code which will compile into
  2. C an xCOD (eXternal CODe) resource for NumberCrunch II.
  3. C
  4. C After building this code resource you must install it into NumberCrunch with either ResEdit or the
  5. C Load xCOD command from inside NCII.
  6. C
  7. C In either case, an sCOD string or resource is also needed to tell NCII what the arguments to this routine are
  8. C     For this routine, an appropriate sCOD is:
  9. C
  10. C    xCOD xSAMPLE_XCODE(J:num; Bj:Array; prog Foo(K:num; Ak:array); Cj:ComplexArray), sets all of Cj[1…J] to 1 + 0i,  Bj[1…j] to 1…j, and passes a K=3 element array [3,2,1] to Foo.
  11. C
  12. C   The procedure arguments are}
  13. C           J        :   extended number}
  14. C            Bj        :   array of extended}
  15. C            foo        :   the name of another xCOD or an NCII user program
  16. C            Cj    :   an array of complex numbers, i.e. a 2J array of extended
  17. C
  18. C
  19.         subroutine SAMPLE_XCOD(zJ, Bj, Foo, Cj)
  20.         implicit extended (a-h, o-z)
  21.         dimension Bj(*), Cj(*), ArrayForFoo(3)
  22.         external Foo
  23. C
  24. C     Convert the array size to an integer.
  25.         J = zJ
  26. C
  27. C     Set the Bj array.
  28.         do i=1,J
  29.           Bj(i) = 1.0*i
  30.         end do
  31. C
  32. C     Set the (real, complex, real, complex, ...) array Cj to 1 + 0i.
  33.         do i=1,J
  34.           Cj(2*i-1) = 1.0
  35.           Cj(2*i) = 0.0
  36.         end do
  37. C
  38. C     Set up the array to pass to the program Foo.
  39.         ArrayForFoo(1) = 3.0
  40.         ArrayForFoo(2) = 2.0
  41.         ArrayForFoo(3) = 1.0
  42.         SizeForFoo = 3.0
  43. C
  44. C     Run the program Foo.
  45.         CALL FOO(SizeForFoo, ArrayForFoo)
  46. C        
  47.         return
  48.         end
  49.